:root {
    --bg: #f5f5f7;
    --accent: #008080;
    --text: #1d1d1f;
    --border: #d2d2d7;
    --radius: 7px;
    --sidebar-width: 380px;
}

/* Disable the ugly blue/grey tap highlight on mobile */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    outline: none !important;
}

/* Prevent text selection on buttons and navigation so they feel like native app components */
button, 
.nav-item, 
.sidebar-item, 
.status-timeline,
.step,
i {
    user-select: none;
    -webkit-user-select: none;
}

/* Prevent the browser from automatically zooming in when an input is focused */
/* (This happens on iOS if font-size is less than 16px) */
input, select, textarea {
    font-size: 16px !important;
}

/* Hide scrollbars but keep functionality for a cleaner look */
::-webkit-scrollbar {
    width: 0px;
    background: transparent;
}

.sidebar-content, 
.main-view, 
.view-section, 
#item-modal-content {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

body, html {
    overscroll-behavior-y: contain; /* Stops pull-to-refresh */
    position: fixed; 
    width: 100%;
    height: 100%;
}

/* 1. Hide scrollbar for Chrome, Safari and Opera */
*::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}

/* 2. Hide scrollbar for IE, Edge and Firefox */
* {
    -ms-overflow-style: none !important;  /* IE and Edge */
    scrollbar-width: none !important;  /* Firefox */
}

/* 3. Special target for your specific modal and list areas */
#item-modal-content, 
.order-list, 
body, 
html {
    -ms-overflow-style: none !important;
    scrollbar-width: none !important;
}




body, html { 
    margin: 0; 
    padding: 0; 
    font-family: 'Inter', sans-serif; 
    background: var(--bg); 
    height: 100vh; 
    overflow: hidden; 
}

.hidden { display: none !important; }

.login-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.login-card {
    background: #fff;
    width: 100%;
    max-width: 340px;
    padding: 30px;
    
    border-radius: 12px;

    text-align: center;
}

.pin-display {
    display: flex;
    justify-content: center;
    gap: 15px;
    
    /* ADD THESE */
    padding: 20px;            /* Internal space around the dots */
    margin: 10px 0 25px 0;    /* External space from ID box and Numpad */
    min-height: 20px;         /* Ensures height is consistent even if empty */
    
    background: #f9f9fb;      /* Subtle background to define the area */
    border: 2px solid #eee;   /* Default light border */
    border-radius: 12px;      /* Matches the rounded style of the num buttons */
    transition: all 0.2s ease;
    cursor: pointer;
}

/* Updated filled state for the dots to look cleaner */
.pin-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #d2d2d7;      /* Default empty color */
    transition: transform 0.2s, background 0.2s;
}

.pin-dot.filled {
    background: var(--accent);
    transform: scale(1.2);    /* Slight pop effect when filled */
}


.numpad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

/* When the user is typing the PIN */
.pin-display-focused {
    border-color: var(--accent) !important;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(0, 128, 128, 0.1); /* Soft glow */
}

.num-btn {
    height: 65px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 600;
    cursor: pointer;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    transition: all 0.1s ease;
}

.num-btn.clear { color: #eb4d4b; border-color: rgba(235, 77, 75, 0.3); }
.num-btn.action { color: var(--accent); border-color: var(--accent); border-width: 2px; }

.staff-app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    background: var(--bg);
}

.order-sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: #fff;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding-left: 20px;
    border-bottom: 1px solid #eee;
}

.brand-container {
    display: flex;
    align-items: center;
    gap: 22px;
}

.brand-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
}

.brand-details {
    display: flex;
    flex-direction: column;
}

.brand-top-line {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-name {
    font-weight: 800;
    font-size: 18px;
    letter-spacing: -0.5px;
    color: var(--text);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #ccc;
    border-radius: 50%;
}

.status-dot.online {
    background: #27ae60;
    box-shadow: 0 0 8px rgba(39, 174, 96, 0.5);
}

.brand-bottom-line {
    display: flex;
    justify-content: space-between;
    width: auto; /* Changed from 120px to auto */
    gap: 15px;   /* Adds spacing between 'Staff App' and the timer */
    margin-top: 2px;
}

.brand-subtext {
    font-size: 10px;
    color: #888;
    font-weight: 600;
}

#last-sync {
    font-size: 9px;
    color: var(--accent);
    font-weight: 800;
}

.sidebar-nav {
    display: flex;
    gap: 10px;
    padding: 10px;
    justify-content: space-around;
    background: #fff;
    border-bottom: 1px solid #eee;
}

.nav-item {
    flex: 1;
    padding: 10px 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    border-radius: 8px;
}

.nav-item.active {
    background: var(--accent);
    color: white;
}

.order-list {
    flex: 1;
    overflow-y: scroll !important;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
   height: 100vh !important;
}

.order-card {
    background: #fff;
    padding: 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    border-left: 6px solid #e0e0e0;
    transition: all 0.2s ease;
}

.order-card.active {
    background: #ffffff;
    border-color: var(--accent);
    border-left-color: var(--accent);
    box-shadow: 0 8px 25px rgba(0,128,128,0.15);
    transform: scale(1.02);
}

.main-view { flex: 1; display: flex; flex-direction: column; }

.view-header { 
    height: 72px; 
    background: #fff; 
    border-bottom: 1px solid var(--border); 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    padding: 0 30px; 
}

.status-timeline {
    display: flex;
    justify-content: space-between;
    margin-bottom: 25px;
    position: relative;
    padding: 0 10px;
}

.status-timeline::before {
    content: '';
    position: absolute;
    top: 15px; left: 40px; right: 40px;
    height: 2px;
    background: #e0e0e0;
    z-index: 1;
}

.step {
    position: relative;
    z-index: 2;
    text-align: center;
    font-size: 10px;
    font-weight: 700;
    color: #b0b0b7;
    text-transform: uppercase;
}

.step-icon {
    width: 32px; height: 32px;
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 5px;
    transition: 0.3s;
}

.step.active .step-icon { border-color: var(--accent); color: var(--accent); background: #f0fafa; }
.step.completed .step-icon { background: var(--accent); color: #fff; border-color: var(--accent); }

#history-details-view {
    display: none;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
}

#finance-view {
    display: none;
    flex-direction: column;
    height: 100vh;
    width: 100%;
    overflow-y: auto;
    padding: 20px;
    background: var(--bg);
}

#history-details-view:not(.hidden), #finance-view:not(.hidden) {
    display: flex !important;
}

.finance-summary-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 25px;
}

.status-stamp {
    display: inline-block;
    padding: 5px 15px;
    border: 3px solid;
    border-radius: 5px;
    font-weight: 900;
    text-transform: uppercase;
    transform: rotate(-10deg);
    opacity: 0.8;
}

.stamp-green { color: #27ae60; border-color: #27ae60; }
.stamp-red { color: #eb4d4b; border-color: #eb4d4b; }

.map-container { flex: 0 0 30%; /* This makes the map take up exactly 40% of the width */; background: #fff; border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; }
#tracking-map { height: 100%; width: 100%; }

.marker-pin {
    width: 30px; height: 30px;
    border-radius: 50% 50% 50% 0;
    position: absolute;
    transform: rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.marker-pin i { transform: rotate(45deg); color: white; }
.marker-customer { background: #3498db; }
.marker-driver { background: var(--accent); }

@keyframes marker-pulse {
    0% { transform: scale(1); opacity: 0.4; }
    100% { transform: scale(2.5); opacity: 0; }
}

/* Container for the detail views */
.view-section {
    display: none; /* Hidden by default */
    flex: 1;
    height: 100%;
    overflow-y: auto;
    padding: 25px;
    box-sizing: border-box;
    background: var(--bg);
}

/* Logic to show the active section */
.view-section:not(.hidden) {
    display: flex !important;
}

/* Order Detail Containers */
.prep-container {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);

}

.section-title {
    font-size: 13px;
    font-weight: 800;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Finance Stats Cards */
.finance-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.stat-card {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border);
    text-align: center;
}

.stat-card label {
    display: block;
    font-size: 11px;
    color: #86868b;
    margin-bottom: 5px;
    font-weight: 600;
}

.stat-card .value {
    font-size: 24px;
    font-weight: 800;
    color: var(--text);
}

/* History Items Table */
.history-item-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f2;
}

.history-item-row:last-child { border-bottom: none; }

.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
}

.modal-card {
    background: #fff;
    width: 90%;
    max-width: 400px;
    border-radius: 16px;
    padding: 0; /* Let internal divs handle padding */
    overflow: hidden;
    animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.notification-popup {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: #fff;
    border-left: 5px solid var(--accent);
    padding: 15px 25px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 10001;
    animation: slideInRight 0.4s ease;
}

.popup-icon {
    font-size: 24px;
    color: var(--accent);
}

/* Status Badge Colors */
.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-live { background: #e3fcef; color: #00875a; }
.badge-sched { background: #deebff; color: #0052cc; }
.badge-past { background: #f4f5f7; color: #5e6c84; }

/* Animations */
@keyframes modalPop {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(235, 77, 75, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(235, 77, 75, 0); }
    100% { box-shadow: 0 0 0 0 rgba(235, 77, 75, 0); }
}

/* Custom Scrollbar for the sidebar */
.order-list::-webkit-scrollbar { width: 6px; }
.order-list::-webkit-scrollbar-track { background: transparent; }
.order-list::-webkit-scrollbar-thumb { background: #d2d2d7; border-radius: 10px; }


.order-list {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.order-card {
    background: #fff;
    padding: 15px;
    border-radius: 12px;
    border: 1px solid var(--border);
    border-left: 5px solid #ddd;
    cursor: pointer;
    transition: all 0.2s ease;
}

.order-card:hover {
    border-color: var(--accent);
    background: #fafafa;
}

.order-card.active {
    border-color: var(--accent);
    border-left-color: var(--accent);
    background: #f0fafa;
    box-shadow: 0 4px 12px rgba(0, 128, 128, 0.1);
}

.order-card-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.order-id { font-weight: 800; font-size: 14px; }
.order-time { font-size: 11px; color: #888; }
.customer-name { font-size: 13px; font-weight: 600; margin: 4px 0; }

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid #eee;
    background: #fff;
}

.store-status-card {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.status-info { display: flex; flex-direction: column; }
#status-text { font-size: 13px; font-weight: 700; }
#status-subtext { font-size: 10px; color: #888; }

.logout-pill {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #ffebeb;
    background: #fff5f5;
    color: #eb4d4b;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: 0.2s;
}

.logout-pill:hover {
    background: #eb4d4b;
    color: #fff;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px; width: 18px;
    left: 3px; bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider { background-color: var(--accent); }
input:checked + .slider:before { transform: translateX(20px); }

.sidebar-nav {
    display: flex;
    gap: 10px;
    padding: 10px;
    justify-content: space-around;
    background: #fff;
    border-bottom: 1px solid #eee;
}

.nav-item {
    flex: 1;
    padding: 10px 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    border-radius: 8px;
    color: #8e8e93;
    transition: all 0.2s ease;
}

.nav-item i { font-size: 18px; }
.nav-item span { font-size: 10px; font-weight: 700; text-transform: uppercase; }

.nav-item.active {
    background: var(--accent);
    color: white;
}

.nav-item:hover:not(.active) {
    background: #f5f5f7;
    color: var(--text);
}

#order-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Ensure the JS 'hidden' class actually removes them */
#order-actions.hidden {
    display: none !important;
}

.btn-primary {
    background: var(--accent);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-primary:hover { opacity: 0.9; }

.btn-cancel {
    background: white;
    color: #eb4d4b;
    border: 1px solid #eb4d4b;
    padding: 10px 15px;
    border-radius: var(--radius);
    font-weight: 700;
    cursor: pointer;
}

.btn-cancel:hover { background: #fff5f5; }

.print-btn-secondary {
    background: white;
    border: 1px solid var(--border);
    padding: 10px;
    border-radius: var(--radius);
    cursor: pointer;
}

/* The most important rule for the JS to work */
.hidden { display: none !important; }

.sidebar-search {
    padding: 15px;
    background: #fff;
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-wrapper i {
    position: absolute;
    left: 12px;
    color: #8e8e93;
    font-size: 14px;
}

.search-wrapper input {
    width: 100%;
    padding: 10px 10px 10px 35px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f5f5f7;
    outline: none;
    font-size: 14px;
}

.search-wrapper input:focus {
    border-color: var(--accent);
    background: #fff;
}

.numpad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 20px;
}

.num-btn {
    aspect-ratio: 1 / 0.7;
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.1s;
}

.num-btn:active { background: #f5f5f7; }
.num-btn.clear { color: #eb4d4b; }
.num-btn.action { background: var(--accent); color: white; border: none; }

/* This ensures the 'hidden' class actually works */
.hidden { 
    display: none !important; 
}

/* This ensures that when the class is removed, the toolbar uses Flexbox */
#order-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.view-header {
    display: flex;
    justify-content: space-between; /* Pushes title to left, buttons to right */
    align-items: center;
    padding: 0 25px;
    height: 70px;
    background: #fff;
    border-bottom: 1px solid var(--border);
}

#order-details-view .prep-container {
    flex: 1; /* This tells the items list to take up the remaining 60% */
    min-width: 400px; /* Prevents the list from getting too squashed */
}

#order-details-view {
    display: flex;
    flex-direction: row; /* Horizontal layout */
    gap: 20px;
    padding: 25px;
    height: 100%;
}




@keyframes modalScale {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Action Buttons within Modals */
.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 45px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    color: white;
    transition: 0.2s;
}

.btn-primary:active {
    transform: scale(0.98);
}

/* Logout Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
}



.modal-icon.logout-icon {
    font-size: 40px;
    color: #eb4d4b;
    margin-bottom: 15px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 25px;
}

.btn-secondary {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #ddd;
    background: #f8f9fa;
    cursor: pointer;
    font-weight: 700;
}

.btn-danger {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    background: #eb4d4b;
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 700;
}


/* The 'checked' state for order items */
.order-item-row {
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid transparent;
}

.order-item-row:hover {
    background: #f8f9fa;
}

/* When the item is clicked/active */
.order-item-row.prepared {
    background: #e3fcef; /* Light green background */
    border-color: #27ae60;
}

.order-item-row.prepared .item-tick {
    color: #27ae60 !important;
}

.order-item-row.prepared .item-name {
    text-decoration: line-through;
    color: #27ae60;
}

/* Base style for each item row */
.item-row {
    display: flex; 
    justify-content: space-between; 
    padding: 12px; 
    border-bottom: 1px solid #eee;
    transition: all 0.2s ease;
    align-items: center;
}

.item-qty {
    color: var(--accent);
    margin-right: 5px;
}

/* Style for live, clickable items */
.clickable-item {
    cursor: pointer;
}

.clickable-item:hover {
    background-color: #f9f9f9;
}

.prep-check {
    color: #d2d2d7; /* Default grey circle */
    font-size: 18px;
    transition: color 0.2s ease;
}

/* THE PREPARED STATE */
.item-row.prepared {
    background-color: #e3fcef !important; /* Soft green background */
    border-bottom-color: #a7f0ba;
}

.item-row.prepared .item-qty,
.item-row.prepared span {
    color: #1a7f37; /* Darker green text */
    text-decoration: line-through; /* Striking through the text */
}

.item-row.prepared .prep-check {
    color: #27ae60; /* Vibrant green checkmark */
}


.order-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #f0f0f2;
    cursor: pointer;
}

.order-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.order-id {
    font-size: 14px;
    font-weight: 800;
    color: var(--text);
}

.customer-name {
    font-size: 13px;
    color: #666;
}

.order-meta {
    text-align: right;
}

.status-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}

/* Status Colors */
.status-accepted { background: #e3fcef; color: #00875a; }
.status-preparing { background: #deebff; color: #0052cc; }
.status-cancelled { background: #ffebe6; color: #de350b; }


/* Custom Marker Styling */
.marker-pin {
    width: 30px;
    height: 30px;
    border-radius: 50% 50% 50% 0;
    background: var(--accent);
    position: absolute;
    transform: rotate(-45deg);
    left: 50%;
    top: 50%;
    margin: -15px 0 0 -15px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.marker-pin i {
    transform: rotate(45deg); /* Fix icon rotation */
    color: white;
    font-size: 14px;
}

/* Color coding for Customer vs Driver */
.marker-customer { background: var(--accent); }
.marker-driver { background: #3498db; }

/* Ensure the map container has height */
#tracking-map {
    height: 100%;
    width: 100%;
    background: #f0f0f0;
    z-index: 1; /* Keep it below modals */
}


/* Container for the notification */
.nova-toast {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translate(-50%, -100%); /* Start hidden above screen */
    width: 90%;
    max-width: 400px;
    background: #fff;
    color: #1e293b;
    padding: 16px 20px;
    
    /* iPhone Safe Area Logic */
    margin-top: calc(env(safe-area-inset-top) + 10px); 
    
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 9999;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-weight: 600;
    pointer-events: none; /* Don't block clicks while disappearing */
}

/* Show state */
.nova-toast.show {
    transform: translate(-50%, 0);
}

/* Type Styling */
.toast-success i { color: #008080; }
.toast-error i { color: #f43f5e; }
.toast-info i { color: #3b82f6; }
.toast-warning i { color: #f59e0b; }

.toast-error { border-left: 5px solid #f43f5e; }
.toast-success { border-left: 5px solid #008080; }


/* Ensure the location modal sits above the Leaflet map */
#location-modal {
    z-index: 9999;
    position: fixed;
}

/* Ensure markers look clickable */
.leaflet-marker-icon {
    cursor: pointer !important;
}

/* Ensure markers are clickable and show the pointer cursor */
.leaflet-marker-icon {
    cursor: pointer !important;
}

/* Optional: Add a little "pulse" to the marker-pin when hovered */
.marker-pin:hover {
    transform: rotate(-45deg) scale(1.1);
    filter: brightness(1.1);
    transition: all 0.2s ease;
}

/* Overlay: Darkens the background */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6); /* Soft dimming */
    backdrop-filter: blur(4px);    /* Modern frosted glass effect */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.3s ease;
}

/* Modal Card: The white box */
.modal-card {
    background: #fff;
    width: 90%;
    max-width: 400px;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Content Styling */
#location-modal-content h3 {
    margin: 0 0 16px 0;
    font-size: 20px;
    color: #2d3436;
    font-weight: 800;
    text-align: center;
}

#location-modal-content hr {
    border: 0;
    border-top: 1px solid #eee;
    margin: 15px 0;
}

#location-modal-content p {
    margin: 10px 0;
    font-size: 15px;
    color: #636e72;
    display: flex;
    justify-content: space-between;
}

#location-modal-content b {
    color: #2d3436;
    font-weight: 600;
}

/* Action Buttons */
.modal-actions {
    margin-top: 24px;
    display: flex;
    gap: 10px;
}

.btn-secondary {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    background: #f1f2f6;
    color: #2d3436;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: #dfe4ea;
}

/* Pop-in animation */
@keyframes modalPop {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}




.plate-badge {
    background: #feca57;
    color: #2d3436;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-weight: 800;
    border: 1px solid #e1b12c;
}

/* Container stays relative so button can be absolute */
.map-container {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

/* The Expand Button - Floating over the map */
.map-control-btn.expand-trigger {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1000; /* Must be higher than Leaflet (400-800) */
    width: 38px;
    height: 38px;
    background: white;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 8px;
    cursor: pointer;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: all 0.2s ease;
}

.map-control-btn.expand-trigger:hover {
    background: #f8f9fa;
    transform: scale(1.05);
    color: var(--accent);
}

/* Ensure the map always fills its parent, no matter the size */
#tracking-map {
    width: 100%;
    height: 100%;
    min-height: 200px; /* Base height for sidebar view */
    z-index: 1;
}

/* Fix for the Expanded State */
.map-container.expanded {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* Perfectly centered */
    width: 85vw;
    height: 80vh;
    z-index: 10001; /* Above everything else */
    background: #fff; /* Prevents seeing through the map before tiles load */
    border-radius: 16px;
    box-shadow: 0 0 0 5000px rgba(0,0,0,0.8); /* Darkens background */
    overflow: hidden; /* Prevents internal scrollbars */
}

/* Prevent the rest of the website from scrolling when map is open */
body.map-open {
    overflow: hidden;
}


.item-main-content {
    display: flex;
    flex-direction: column;
    padding-right: 10px;
}

.product-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: #333;
}

.item-modifiers {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 4px;
    padding-left: 25px; /* Indent under product name */
    color: #e67e22; /* Accent color for customizations */
    font-size: 0.9rem;
    font-weight: 500;
}

.item-modifiers i {
    margin-top: 3px;
    font-size: 0.8rem;
    opacity: 0.7;
}

.item-row.prepared .item-modifiers {
    color: #bdc3c7;
    text-decoration: none; /* Keep modifiers readable even if product is crossed out */
}


.btn-verify-pickup {
    background: #6c5ce7; /* Distinct purple color */
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.2s;
}

.btn-verify-pickup:hover {
    background: #a29bfe;
}

/* If the mission is already verified or locked, we can style it differently */
.btn-verify-pickup:disabled {
    background: #dfe6e9;
    cursor: not-allowed;
}



/* Hidden helper */
.hidden {
    display: none !important;
}


/* The Grid Container */
#menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 20px;
    padding: 20px;
}

/* Individual Menu Tiles */
.menu-tile {
    background: white;
    border-radius: 15px;
    padding: 15px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    border: 1px solid #eee;
}

.menu-tile:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}

/* The Image inside the tile */
.menu-tile img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 10px;
    margin-bottom: 10px;
}





/* Item Name Styling */
.item-name {
    font-weight: bold;
    font-size: 1.1rem;
    color: #333;
}

/* Out of Stock (86ed) Styling */
.menu-tile.oos {
    opacity: 0.6;
    filter: grayscale(0.8);
    background: #f9f9f9;
}

/* Status Dot */
.status-dot {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
}

.status-available { background: #2ecc71; }
.status-oos { background: #e74c3c; }

/* Modal Overlay (The "weird" background) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7); /* Darken this to make modal pop */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 20px;

    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.hidden { display: none !important; }

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8); /* Darkens the background */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}


#menu-view {
    height: 100vh;
    display: flex;
    flex-direction: column;
}s

.view-header {
    flex-shrink: 0; /* Don't let the header squish */
    padding: 20px;
    background: #fff;
    border-bottom: 1px solid var(--border);
}

/* This is the container we want to scroll */
#menu-grid {
    flex: 1;                /* Fill remaining height */
    overflow-y: auto;       /* Enable vertical scrolling */
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 20px;
    align-content: start;   /* Prevents items from stretching vertically */
    
    /* Optional: Make the scrollbar look cleaner on tablets */
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
}

.menu-tile {
    height: 220px; /* Set a fixed height so they align perfectly in rows */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: white;
    border-radius: 12px;
    padding: 10px;
    border: 1px solid #eee;
}

.menu-tile img {
    width: 100%;
    height: 110px; /* Force the image to stay small */
    object-fit: cover;
    border-radius: 8px;
}

.item-name {
    font-size: 0.9rem;
    font-weight: 700;
    /* Prevent long names from breaking the tile */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Sidebar base transition */
.order-sidebar {
    position: relative;
    transition: transform 0.3s ease, width 0.3s ease;
    width: 300px; /* Adjust to your current width */
}

/* Collapsed state */
.order-sidebar.collapsed {
    transform: translateX(-300px); /* Slides it off screen */
    width: 0;
    margin-right: 0;
    padding: 0;
    overflow: visible; /* Keeps handle visible */
}

/* The Handle Button */
.sidebar-toggle {
    display: none !important;
    position: absolute;
    right: -30px; /* Pulls it outside the sidebar */
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 60px;
    background: #fff;
    border: 1px solid #eee;
    border-left: none;
    border-radius: 0 10px 10px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 4px 0 10px rgba(0,0,0,0.05);
    z-index: 100;
    color: #888;
}

.sidebar-toggle:hover {
    color: #008080;
}

/* Rotate icon when collapsed */
.order-sidebar.collapsed #toggle-icon {
    transform: rotate(180deg);
}

.main-view {
    flex-grow: 1; /* This makes it take up all remaining space */
    background: #f8f9fa;
    overflow-y: auto;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); /* Match the sidebar speed */
    padding: 0px;
}
/* The Parent Wrapper */
.main-app {
    display: flex !important;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}


.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; border-radius: 24px; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: #f59f00; }
input:checked + .slider:before { transform: translateX(20px); }

#item-modal-content {
    width: 100% !important;
    min-width: 600px !important;
    padding: 20px !important;
    height: 80vh !important;
    padding-top: 40px !important;
    
    /* ADD THESE TO CENTER INTERNAL CONTENT */
    display: flex !important;
    flex-direction: column !important;

    box-sizing: border-box;
    overflow-y:  auto !important;
}


    /* The Menu version stays compact and sits at the top */
    .menu-version {
        min-height: 0 !important;
        height: auto !important;
        flex: none !important;
        display: block;
        overflow-y: auto !important;
    }
/* --- COMPREHENSIVE MOBILE OVERRIDE --- */

/* 1. Base Class for Desktop (Hidden) */
.mobile-back-btn {
    display: none;
}



@media (max-width: 768px) {
    /* 2. Slide-Over Panel Logic */
    .main-view {
        position: fixed !important;
        top: 0;
        right: -100%; /* Hidden by default */
        width: 100%;
        height: 100vh;
        z-index: 1000;
        background: white;
        transition: right 0.3s ease-in-out;
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        overflow-x: hidden !important;
    }
    .login-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: #f0f0f2;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

    .login-screen {
        padding-top: env(safe-area-inset-top);
        height: 100vh !important;
        margin: 0 !important;
    }
    .login-card {
        padding-top: 150px;
        height: 100vh;
        width: 100%;
        border-radius: 0px;
    }

    .main-view.active {
        right: 0 !important; /* Slide in trigger */
    }

    /* 3. Mobile Header & Back Button */
    .view-header {
        padding: 15px;
        display: flex;
        align-items: center;
        gap: 15px;
        border-bottom: 1px solid #eee;
        background: #fff;
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .mobile-back-btn {
        display: block !important;
        font-size: 1.2rem;
        color: var(--cds-interactive-01);
        padding-right: 10px;
        background: none;
        border: none;
        cursor: pointer;
    }

    /* 4. The Details Container (Prep Container) */
    .prep-container {
        min-width: 0 !important; /* Reset 400px desktop width */
        
        padding: 15px !important;
        margin-bottom: 10px !important;
    }

    /* 5. Order Details Vertical Proportions */
    #order-details-view {
        display: flex !important;
        flex-direction: column !important;
        height: 100% !important;
    }

    #order-details-view .prep-container {
        flex: 1 0 auto;
        min-height: 60vh; /* Make order info tall */
        order: 1;
    }

    /* 6. Map Logic (Bottom of scroll) */
    .map-container {
        order: 2; /* Force map to bottom */
        flex: 0 0 300px;
        height: 300px !important;
        min-height: 300px !important;
        margin-top: 20px;
        border-top: 2px solid #eee;
        position: relative;
    }

    #tracking-map {
        height: 100% !important;
        width: 100% !important;
    }

    /* 7. Menu & Stock View Reset */
    /* This ensures the Menu page doesn't have the huge 60vh gap */
    #menu-view .prep-container {
        min-height: 0 !important;
        height: auto !important;
        flex: none !important;
    }

    .menu-tiles-container {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
        gap: 10px !important;
        padding: 10px !important;
    }

    /* Utility to hide the "Select an Order" ghost message when on Menu view */
    #menu-view .view-header #active-order-title h3 {
        font-size: 1.1rem;
    }
}


@media (max-width: 768px) {
/* Sidebar base transition */
.order-sidebar {
    position: relative;
    display: flex;
    flex-direction: column;
    /* Use dvh (Dynamic Viewport Height) for mobile to ignore the URL bar */
    height: 100vh; 
    height: 100dvh; 
    width: 100% !important;
    background: #fff;
    overflow: hidden;
    transition: transform 0.3s ease;
    z-index: 10;
}

/* Header area where your logo likely lives */
.sidebar-header {
    flex-shrink: 0; /* Prevents logo from squishing */
    padding: 15px;
    z-index: 11;
    height: 10px;
}

/* The scrollable list area */
.order-list {
    flex-grow: 1; /* Takes up remaining space */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling for iOS */
    padding-bottom: 80px; /* Space for the footer */
}

.sidebar-footer {
    position: sticky;
    bottom: 0;
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
    border-top: 1px solid #eee;
    background: #fff;
    flex-shrink: 0;
    z-index: 12;
}
    /* The Order version stays tall and has the map at the bottom */
    .orders-prep {
        flex: 1 0 auto !important;
        min-height: 60vh !important;
        display: block;
    }

    /* The Menu version stays compact and sits at the top */
    .menu-version {
        min-height: 0 !important;
        height: auto !important;
        flex: none !important;
        display: block;
    }


    /* If one is hidden via JS, make sure it stays GONE */
    .prep-container.hidden {
        display: none !important;
    }

    

    /* Place this at the absolute bottom of merchant front end.css */
    .hidden, 
    #order-details-view.hidden, 
    #history-details-view.hidden, 
    #menu-view.hidden,
    .prep-container.hidden {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }



}

@media (max-width: 768px) {
    /* Ensure the body doesn't bounce or show white space behind the app */
    body {
        padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
        height: 100vh;
        overflow: hidden;
    }
    .modal-content {
        border-radius: 0 !important;
    }

    /* Modal Mobile Adjustments */
    #item-modal {
    
        align-items: center !important; /* Keep it centered on mobile too */
    }
#item-modal-content {
    width: 100% !important;
    min-width: 100% !important;
    padding: 20px !important;
    height: 90vh !important;
    padding-top: 40px !important;
    
    /* ADD THESE TO CENTER INTERNAL CONTENT */
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important; 
    background: #fff; /* Ensure it's not transparent */
    box-sizing: border-box;
    overflow-y:  auto !important;
}

/* Ensure the wrapper for the image/header stays centered */
#item-modal-content > div {
    width: 100%;
    max-width: 600px; /* Keeps it from stretching too wide on desktop */
}

/* Fix for the Ingredients List to ensure it doesn't look weird when centered */
#item-modal-content .ingredients-container {
    text-align: left; /* Keep text left-aligned inside a centered container */
}

/* Target the div containing the Name, Price, and Status */
#item-modal-content > div:first-child > div:last-child {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
}

/* Fix the Status Span overlap */
#item-modal-content > div:first-child > div:last-child span {
    display: inline-block !important; /* This stops the overlap */
    margin-top: 12px !important;      /* Push it down away from the price */
    width: fit-content !important;    /* Don't let the background stretch full width */
}

/* Tablet & Mobile adjustment */
@media (max-width: 768px) {
    #item-modal-content > div:first-child {
        flex-direction: column !important;
        text-align: center !important;
        gap: 15px !important;
    }

    #item-modal-content > div:first-child > div:last-child {
        align-items: center !important;
    }
}

    /* Fix buttons for thumb-reach and safe areas */
    .modal-actions, .close-btn-container {
        padding-bottom: env(safe-area-inset-bottom) !important;
    }

    /* Side-panel mobile inset fix */
    .main-view.active {
        padding-top: env(safe-area-inset-top);
        height: calc(100vh - env(safe-area-inset-top));
    }

    

}



@media (max-width: 768px) {
    /* 1. Adjust the header container */
    .view-header {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding: 10px 15px !important;
        gap: 10px !important;
        min-height: 60px;
    }

    /* 2. Make the title flexible so it doesn't push buttons off-screen */
    #active-order-title {
        flex: 1; 
        min-width: 0; /* Allows text truncation if title is too long */
    }

    #active-order-title h3 {
        font-size: 1rem !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin: 0 !important;
    }

    /* 3. Handle the buttons container */
    #order-actions {
        display: flex !important;
        gap: 6px !important;
        flex-shrink: 0; /* Prevents buttons from squishing */
    }

    /* 4. Optimize individual button sizes for narrow screens */
    #order-actions button {
        padding: 8px 10px !important;
        font-size: 12px !important;
        height: 38px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Keep print button compact */
    .print-btn-secondary {
        width: 38px;
        padding: 0 !important;
    }

    /* Make the primary action slightly more prominent but still fitting */
    #main-action-btn {
        padding: 8px 12px !important;
        min-width: 100px;
    }

    /* Show the back button properly alongside the others */
    .mobile-back-btn {
        display: block !important;
        padding: 0 5px !important;
        margin-right: 5px;
        flex-shrink: 0;
    }
}




body {
    /* Prevents the browser from handling horizontal swipes (like 'go back') 
       so our JS can take over exclusively */
    touch-action: pan-y; 
    overscroll-behavior-x: none;
}

/* Ensure the views transition smoothly when switched */
.view-section {
    animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateX(10px); }
    to { opacity: 1; transform: translateX(0); }
}


/* 1. Desktop & Global: Keep the header flexible */
.menu-version > div:first-child {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    width: 100%;
    box-sizing: border-box;
}

/* 2. Desktop Fix: Prevent pushing off-screen */
.menu-version .search-box {
    max-width: 250px; /* Limits size on desktop */
    width: 100%;      /* Allows it to be responsive */
    flex-shrink: 0;   /* Prevents it from squishing too small */
    margin-right: 40px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #ccc; /* Default gray */
    display: inline-block;
    transition: background-color 0.3s ease;
}

/* Pulsing effect for the "Live" green dot */
.status-dot.pulse {
    box-shadow: 0 0 0 0 rgba(46, 213, 115, 0.7);
    animation: dot-pulse 2s infinite;
}

@keyframes dot-pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(46, 213, 115, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(46, 213, 115, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(46, 213, 115, 0); }
}

.brand-subtext {
    font-size: 10px;
    text-transform: uppercase;
    opacity: 0.6;
    margin-right: 8px;
}

#last-sync {
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 0.5px;
}

/* 3. Mobile: Center Everything */
@media (max-width: 600px) {
    .menu-version > div:first-child {
        flex-direction: column !important;
        text-align: center !important;
        justify-content: center !important;
        align-items: center !important; /* Centers children horizontally */
    }

    /* Target the text div (Title + P) to center its content */
    .menu-version > div:first-child > div:first-child {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
        margin-bottom: 15px;
    }

    .menu-version .search-box {
        max-width: 100% !important; /* Remove desktop limit */
        width: 100% !important;
        display: flex;
        justify-content: center;
        margin-right: 0px !important;
    }

    .menu-version .search-box input {
        text-align: center; /* Centers the placeholder text */
        width: 100% !important;
    }
    .modal-card{
        width: 70% !important;
    }
    
}




/* 1. Prevent the whole app from bouncing/pulling down */
html, body {
    position: fixed;
    overflow: hidden;
    width: 100%;
    height: 100%;
    /* Prevents the 'pull-to-refresh' bounce on Chrome/Android */
    overscroll-behavior-y: none; 
}

/* 2. Enable smooth, stable scrolling on your actual lists */
.order-list, 
.menu-tiles-container, 
#item-modal-content,
.prep-container {
    overflow-y: auto !important;
    /* Native-feeling momentum scroll for iOS */
    -webkit-overflow-scrolling: touch; 
    /* Prevents scroll chaining (bouncing the parent when you hit the end) */
     
}





